package com.example.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.app.entity.Collect;
import com.example.app.entity.Consumer;
import com.example.app.entity.Song;
import com.example.app.service.ICollectService;
import com.example.app.service.IConsumerService;
import com.example.app.service.ISongService;
import com.example.common.config.ConfigProperties;
import com.example.common.config.TransWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
public class VideoController {
    @Autowired
    private ConfigProperties configProperties;

    @GetMapping("/video/group/list")
    public Map<String, Object> videoGroupList(HttpServletRequest request){

        List<GroupList> groupLists = new ArrayList<>();

        groupLists.add(new GroupList(1, "现场"));
        groupLists.add(new GroupList(2, "翻唱"));
        groupLists.add(new GroupList(3, "舞蹈"));
        groupLists.add(new GroupList(4, "听BGM"));
        groupLists.add(new GroupList(5, "万有引力"));
        groupLists.add(new GroupList(6, "告白"));
        groupLists.add(new GroupList(7, "云村放映厅"));
        groupLists.add(new GroupList(8, "超然联盟"));
        groupLists.add(new GroupList(9, "相信未来1"));
        groupLists.add(new GroupList(10, "热歌看得见"));


        Map<String, Object> data = TransWrapper.wrap("data", groupLists);

        return data;
    }

    @GetMapping("/video/group")
    public Map<String, Object> videoGroup(HttpServletRequest request){

        String id = request.getParameter("id");

        List<Group> groups = new ArrayList<>();
        String nginxBasePath = configProperties.getNginxBasePath();

        for (int i = 0; i < 5; i++) {
            groups.add(new Group(new Data(new UrlInfo(nginxBasePath + "/mv/"+i+".mp4"),
                    nginxBasePath + "/img/singerPic/zjl"+(i+1)+".jpg",
                    i,i,
                    new Creator("周杰伦", nginxBasePath+"/avatorImages/zjl"+(i+1)+".jpg"),
                    999+i,999+(2*i))));
        }
        Map<String, Object> data = TransWrapper.wrap("datas", groups);

        return data;
    }

    public static class UrlInfo{
        private String url;

        public UrlInfo(String url) {
            this.url = url;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }
    }
    public static class Creator{
        private String nickname;
        private String avatarUrl;

        public Creator(String nickname, String avatarUrl) {
            this.nickname = nickname;
            this.avatarUrl = avatarUrl;
        }

        public String getAvatarUrl() {
            return avatarUrl;
        }

        public void setAvatarUrl(String avatarUrl) {
            this.avatarUrl = avatarUrl;
        }

        public String getNickname() {
            return nickname;
        }

        public void setNickname(String nickname) {
            this.nickname = nickname;
        }
    }

    public static class Data{
        private UrlInfo urlInfo;
        private String coverUrl;
        private Integer vid;
        private Integer id;
        private Creator creator;
        private Integer praisedCount;
        private Integer commentCount;

        public Data(UrlInfo urlInfo, String coverUrl, Integer vid, Integer id, Creator creator, Integer praisedCount, Integer commentCount) {
            this.urlInfo = urlInfo;
            this.coverUrl = coverUrl;
            this.vid = vid;
            this.id = id;
            this.creator = creator;
            this.praisedCount = praisedCount;
            this.commentCount = commentCount;
        }

        public Integer getPraisedCount() {
            return praisedCount;
        }

        public void setPraisedCount(Integer praisedCount) {
            this.praisedCount = praisedCount;
        }

        public Integer getCommentCount() {
            return commentCount;
        }

        public void setCommentCount(Integer commentCount) {
            this.commentCount = commentCount;
        }

        public Creator getCreator() {
            return creator;
        }

        public void setCreator(Creator creator) {
            this.creator = creator;
        }

        public Integer getId() {
            return id;
        }

        public void setId(Integer id) {
            this.id = id;
        }

        public Integer getVid() {
            return vid;
        }

        public void setVid(Integer vid) {
            this.vid = vid;
        }

        public UrlInfo getUrlInfo() {
            return urlInfo;
        }

        public void setUrlInfo(UrlInfo urlInfo) {
            this.urlInfo = urlInfo;
        }

        public String getCoverUrl() {
            return coverUrl;
        }

        public void setCoverUrl(String coverUrl) {
            this.coverUrl = coverUrl;
        }
    }

    public static class Group{
        private Data data;

        public Group(Data data) {
            this.data = data;
        }

        public Data getData() {
            return data;
        }

        public void setData(Data data) {
            this.data = data;
        }
    }

    public static class GroupList{
        private Integer id;
        private String name;

        public GroupList(Integer id, String name) {
            this.id = id;
            this.name = name;
        }

        public Integer getId() {
            return id;
        }

        public void setId(Integer id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

}
